﻿using DAL.ModelView;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class KhachHangDAL
    {
        private QLPKDataContext qlpk;
        public KhachHangView InsertKhachHang(Khachhang kh)
        {           
            qlpk = new QLPKDataContext();
            KhachHangView khv = new KhachHangView();
            try
            {
                var khachHang = new Khachhang
                {         
                    TenKH = kh.TenKH,
                    DiaChi = kh.DiaChi,
                    DienThoai = kh.DienThoai,
                    Namsinh = kh.Namsinh,
                    phai = kh.phai == "Nam" ? "Nam" : "Nữ"
                    
                };
                qlpk.Khachhangs.InsertOnSubmit(khachHang);
                qlpk.SubmitChanges();
                khv.TenKH = kh.TenKH.ToString();
                return khv;
            }
            catch (Exception ex)
            {
                return khv;
            }
        }
    }
}
